<template>
  <div class="r">
    <div class="booklist">
      <div class="top">
        <div><p>审核</p></div>
        <div class="close" @click="closeDiv">x</div>
      </div>

      <!-- <p>{{toSonData}}</p> -->
      <div class="center">
        <p><span>书名：</span>{{ toSonData.name }}</p>
        <p><span>出版社：</span>{{ toSonData.publisher }}</p>
        <p><span>分类：</span>{{ toSonData.type }}</p>
        <p><span>作者：</span>{{ toSonData.author }}</p>
        <p><span>ISBN：</span>{{ toSonData.ISBN }}</p>
        <p><span>数量：</span>{{ toSonData.grade }}</p>
        <p><span>价格：</span>{{ toSonData.price }}</p>
        <p><span>地址：</span>{{ toSonData.address }}</p>
      </div>

      <div class="btn">
        <button @click="golist(1)">通过</button>
        <button @click="golist(2)">不通过</button>
      </div>
    </div>
  </div>
</template>

<script>
import { request } from "../../server_Api";
export default {
  name: "relstatus",
  props: ["toSonData"],
  data() {
    return {
      bid: "",
      value: "",
    };
  },

  created() {
    console.log(this.toSonData, "所有");
    this.value = this.toSonData.relstatus;
  },
  methods: {
    golist(value) {
      // this.$router.history.go(0)
      request({
        url: "/pc_pass",
        method: "POST",
        data: { bid: this.toSonData.bid, value },
      }).then((res) => {
        console.log(res);
          if (value === 1) {
            this.toSonData.relstatus = 1;
             this.$emit("close", false);
              this.$router.history.go(0)
            console.log(1);
          } else if (value === 2) {
            this.toSonData.relstatus = 2;
             this.$emit("close", false);
            this.$router.history.go(0)
          } else {
            this.$emit("close", false);
          }
      });
    },
    closeDiv() {
      this.$emit("close", false);
    },
  },

  // watcher
};
</script>

<style scoped>
.r {
  background: rgba(0, 0, 0, 0.3);
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
}
.booklist {
  width: 30%;
  height: 56%;
  background: #fff;
  margin: 10% auto;
  border-radius: 10px;
  text-align: left;
}
.btn {
  padding: 30px 40px;
  text-align: right;
}
.btn button {
  background: none;
  border: none;
  outline: none;
  padding: 8px 16px;
  margin-left: 20px;
  font-weight: 600;
}
.btn button:first-of-type {
  background: #2897ff;
  color: #fff;
  font-weight: 500;
  border-radius: 4px;
}
.btn button:nth-child(2) {
  background: rgba(0, 0, 0, 0.2);
  color: rgba(0, 0, 0, 0.3);
  font-weight: 500;
}
.booklist .top {
  display: flex;
  margin: 20px;
  justify-content: space-between;
  align-items: center;
  padding: 40px 20px 10px 20px;
}
.booklist .top div:first-of-type {
  font-size: 24px;
  color: #2897ff;
  font-weight: 500;
}
.booklist .top div:last-of-type {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  text-align: center;
  line-height: 20px;
  color: rgba(0, 0, 0, 0.5);
  font-weight: 500;
  border-radius: 50%;
}
.center {
  padding: 0 20px 0 40px;
}
.center p:first-of-type {
  color: #2897ff;
}
.center p {
  margin-top: 10px;
}
.center span {
  color: rgba(0, 0, 0, 0.5);
}
</style>